package com.cp.helper.controller;

import com.cp.helper.bean.Project;
import com.cp.helper.dao.impl.ProjectDao;
import com.cp.helper.enums.ProjectRemindFlagEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * @描述:
 * @Author : chenpeng
 * @Date : 2015/10/13 20:22
 */
@Controller
@RequestMapping("/project")
public class ProjectController {

    @Autowired
    private ProjectDao projectDao;

    /**
     * 描述:添加项目
     *
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    @RequestMapping("/add_project")
    @ResponseBody
    public Object addProject(HttpServletRequest request, HttpServletResponse response) throws Exception {
        Map<String, Object> rtnMap = new HashMap<String, Object>();
        Project project = new Project();
        project.setOwnerId(1);
        project.setProjectName("项目:" + System.currentTimeMillis());
        project.setRemindFlag(ProjectRemindFlagEnum.HAS_REMIND.getValue());
        project.setStatusFlag("HAS_FINISHED");

        projectDao.insert(project);
        rtnMap.put("success", true);
        return rtnMap;
    }
}
